
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>

#define COLOR_RED     "\x1b[31m"
#define COLOR_GREEN   "\x1b[32m"
#define COLOR_YELLOW  "\x1b[33m"
#define COLOR_BLUE    "\x1b[34m"
#define COLOR_MAGENTA "\x1b[35m"
#define COLOR_CYAN    "\x1b[36m"
#define COLOR_RESET   "\x1b[0m"

void type_text(const char *text, int speed) {
    const char *colors[] = {COLOR_RED, COLOR_GREEN, COLOR_YELLOW, 
                           COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN};
    int color_count = 6;
    
    srand(time(NULL));
    
    while(*text) {
        printf("%s%c%s", colors[rand() % color_count], *text, COLOR_RESET);
        fflush(stdout);
        usleep(speed * 1000);
        text++;
    }
}

int main() {
    printf("\n");
    type_text("Hello, Linux World!!!!!!BYR!!!\n", 100);
    type_text("I forgot to make a self-introduction, I am 小由", 100); //This is a bug fix
    
    printf("\n\n");
    type_text("This is a colorful terminal greeting!\n", 80);
    printf("\n");
    type_text("I should keep working on develop this program\n", 80);
    
    printf("\n\n");
    for(int i = 0; i < 3; i++) {
        printf(".");
        fflush(stdout);
        usleep(300000);
    }
    
    printf("\n\n");
    return 0;
}
